package cn.mdmbct.spring.starter.douyin.common.properties.storage;

import cn.mdmbct.douyin.common.enums.StorageType;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;

/**
 * 存储配置
 *
 * @author mdmbct  mdmbct@outlook.com
 * @date 2021/4/25 13:44
 * @modified mdmbct
 * @since 1.0
 */
@Getter
@ConfigurationProperties(StorageProperties.PREFIX)
public class StorageProperties implements Serializable {

    public static final String PREFIX = "dy.open.storage";

    private static final long serialVersionUID = -7598948644731603256L;

    /**
     * 存储类型 默认使用redis_template
     */
    private StorageType type = StorageType.REDIS_TEMPLATE;

    /**
     * 使用{@link StorageType#MEMORY}时 内存中存储的配置和token存储在硬盘中的位置 只需要设置文件夹<p>
     * 默认存储位置./data/dy
     */
    private String memoryLocalSave = "./data/dy";

    /**
     * jedis pool配置<p>
     * 使用{@link StorageType#JEDIS}需配置<p>
     * 如果不配置 则寻找IOC中的JedisPool实例
     */
    private JedisProperties jedis = new JedisProperties();

    public void setType(StorageType type) {
        this.type = type;
    }

    public void setMemoryLocalSave(String memoryLocalSave) {
        this.memoryLocalSave = memoryLocalSave;
    }

    public void setJedis(JedisProperties jedis) {
        this.jedis = jedis;
    }
}